from Factors.General import *


def TurnoverCallBack(dfFundamental, factorName, params):
    pass


def CalcOprationFactor(database, instruments, datetime1, datetime2, update=False):


    for type in ["LYR","TTM"]:
        #
        CalcFundamentalFactor(database, instruments, datetime1, datetime2,
                              factorName="AssetTurnover_" + type,
                              fields=["TotalAsset"],
                              quarterlyFields=["Sales"],
                              callback=DivideCallback,
                              params={"Numerator": "Sales", "Denominator": "TotalAsset", "Type": type},
                              update=update)

        CalcFundamentalFactor(database, instruments, datetime1, datetime2,
                              factorName="FixedAssetTurnover_" + type,
                              fields=["PPE"],
                              quarterlyFields=["Sales"],
                              callback=DivideCallback,
                              params={"Numerator": "Sales", "Denominator": "PPE", "Type": type},
                              update=update)
        #
        CalcFundamentalFactor(database, instruments, datetime1, datetime2,
                              factorName="CurrentAssetTurnover_" + type,
                              fields=["CurrentAsset"],
                              quarterlyFields=["Sales"],
                              callback=DivideCallback,
                              params={"Numerator": "Sales", "Denominator": "CurrentAsset", "Type": type},
                              update=update)

        CalcFundamentalFactor(database, instruments, datetime1, datetime2,
                              factorName="ReceivableTurnover_" + type,
                              fields=["Receivable"],
                              quarterlyFields=["Sales"],
                              callback=DivideCallback,
                              params={"Numerator": "Sales", "Denominator": "Receivable", "Type": type},
                              update=update)
        #
        CalcFundamentalFactor(database, instruments, datetime1, datetime2,
                              factorName="InventoryTurnover_" + type,
                              fields=["Inventory"],
                              quarterlyFields=["Sales"],
                              callback=DivideCallback,
                              params={"Numerator": "Sales", "Denominator": "Inventory", "Type": type},
                              update=update)
